<template>
  <div class="myopinion">
    <topbar_back :back-url="backUrl" back-content="返回"
                 center-content="意见反馈" content-color="black" is-show-center="true"></topbar_back>
    <writing v-if="isShowWriting" @submitOpinion="submitOpinion()"></writing>
    <finished v-else></finished>
  </div>
</template>

<script>
import topbarBack from '../../components/public/topbar_back'
import writing from '../Opinion/writing'
import finished from '../Opinion/finished'
export default {
  name: 'UploadOpinion',
  data () {
    return {
      backUrl: '',
      isShowWriting: true
    }
  },
  components: {
    topbar_back: topbarBack,
    writing: writing,
    finished: finished
  },
  beforeRouteEnter (to, from, next) {
    // alert(from.name + '\n' + to.name)
    // 一定要调用next方法来resolve这个钩子
    // 在此处无法使用this，使用下面的方式来改变对象里面的值
    next(vm => {
      vm.backUrl = from.name
    })
  },
  methods: {
    submitOpinion () {
      // alert('hello')
      this.isShowWriting = false
    }
  }
}
</script>

<style lang="scss" scoped>
.myopinion{
  width: 100%;
  height: 100%;
  background-color: $background-color;
}
</style>
